package com.api.gbhg.huangwm.cron;

import java.util.*;

import com.api.gbhg.huangwm.dao.ProjectOperationDao;
import com.api.gbhg.huangwm.dao.ReimbursementListDao;
import com.customization.commons.LogTool;
import weaver.conn.RecordSet;
import weaver.general.GCONST;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;

/**
 * @Author	Huangwm
 * @Date 2022-04-15
 * @Version 1.0
 * @description TODO 获取历史报销记录,写入中间表 uf_bxjl_kj,uf_bxjl_kj_dt1,uf_bxjl_kj_dt2
 */
public class GetHistoryReimbursement extends BaseCronJob{
	private LogTool logTool = new LogTool("/log/gbhg/huangwm/cron/GetHistoryReimbursement",false);
	private List<String> fullDetailTable_fysx = Arrays.asList(
		"formtable_main_892","formtable_main_897","formtable_main_899","formtable_main_901","formtable_main_902"
	);
	private List<String> fullDetailTable_other = Arrays.asList(
			"formtable_main_895","formtable_main_903","formtable_main_904"
	);
	private List<String> fullDetailTable_RY = Arrays.asList(
			"formtable_main_913","formtable_main_914","formtable_main_915","formtable_main_916","formtable_main_917"
	);

	//记录主表
	public String sql1 = "insert into uf_bxjl_kj(requestid,lcid,jbr,jbks,jbbm,sqrq,bxdbh,shkj,shrq,dqjdid,dqjdlx)values(?,?,?,?,?,?,?,?,?,?,?)";
	//记录明细1
	public String sql2 = "insert into uf_bxjl_kj_dt1(lcid,mxid,fysx,zflx,ysxm,bmjjzcfl,zfjjzcfl,bxkmdm,zcqd,ysly,zcgnkm,zfl,sqbxje,tybxje)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
	//记录明细2
	public String sql3 = "insert into uf_bxjl_kj_dt2(lcid,mxid,zffs,zzlx,fkyx,fkzh,sqzfje,tyzfje,gwkskje)values(?,?,?,?,?,?,?,?,?)";

	public static void main(String[] args) {
		String rootPath = "D:\\WEAVER\\ecology\\";
		GCONST.setRootPath(rootPath);
		GCONST.setServerName("ecology");
		GetHistoryReimbursement action = new GetHistoryReimbursement();
		action.getBx16();
	}

	/*
	 * 固定获取当前已有报销流程的记录
	 * 每次同步前先重置表
	 */
	@Override
	public void execute() {
		runBefore();
		GetHistoryReimbursement historyReimbursement = new GetHistoryReimbursement();
		historyReimbursement.getBx04();
		historyReimbursement.getBx15();
		historyReimbursement.getBx16();
		historyReimbursement.getFulllDetail_fysx();
		historyReimbursement.getFulllDetail_other();
		historyReimbursement.getFulllDetail_RY();
		historyReimbursement.getBx06();
		historyReimbursement.getBx10();
		historyReimbursement.getBx27();
		runAfter();

		ReimbursementListDao listDao = new ReimbursementListDao();
		listDao.runAfter2();//事后同步支出渠道
	}

	public void runBefore() {
		new RecordSet().execute(" truncate table uf_bxjl_kj ");
		new RecordSet().execute(" truncate table uf_bxjl_kj_dt1 ");
		new RecordSet().execute(" truncate table uf_bxjl_kj_dt2 ");
	}

	public void runAfter(){
		new RecordSet().execute("update uf_bxjl_kj set sqbxje=(select sum(sqbxje) from uf_bxjl_kj_dt1 where uf_bxjl_kj_dt1.lcid=uf_bxjl_kj.lcid)," +
				 				"tybxje=(select sum(tybxje) from uf_bxjl_kj_dt1 where uf_bxjl_kj_dt1.lcid=uf_bxjl_kj.lcid) ");
	}

	/**
	 * BX04 公务出行费用报销 formtable_main_894
	 * @return
	 */
	public void getBx04(){
		logTool.writeLog("同步BX04开始");
		String table = "formtable_main_894";
		String zy_dbname = "ccsywb";//摘要字段
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		RecordSet rs4 = new RecordSet();
		RecordSet getNodeInfo = new RecordSet();
		List<List> mainDatas = new ArrayList<>();
		List<List> dt1Datas = new ArrayList<>();
		List<List> dt2Datas = new ArrayList<>();
		//获取主表信息
		String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype  from "+table+" fm "
				+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
				+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
				+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
				+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
		rs1.execute(mainSql);
		while(rs1.next()){
			String id = rs1.getString("id");
			String requestid = rs1.getString("requestid");
			String jbr = rs1.getString("jbr");
			String jbks = rs1.getString("jbks");
			String jbbm = rs1.getString("jbbm");
			String sqrq = rs1.getString("sqrq");
			String lcbh = rs1.getString("lcbh");
			String currentnodeid = rs1.getString("currentnodeid");
			String currentnodetype = rs1.getString("currentnodetype");
			//获取会计节点的审核人和审核时间
			String operUserid = "";
			String operDate = "";
//			String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//					") and userid=(\n" +
//					"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
			String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
			getNodeInfo.execute(nodeSql);
			if(getNodeInfo.next()){
				operUserid = getNodeInfo.getString("userid");
				operDate = getNodeInfo.getString("operatedate");
			}
			Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
			List<String> maindata = new ArrayList<>();
			for (Object obj : mainParams){
				maindata.add(obj.toString());
			}
			mainDatas.add(maindata);

			rs2.execute("select id,"+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxje,tybxje from "+table+"_dt1 where mainid="+id);
			while(rs2.next()){
				String dt1_id = rs2.getString("id");
				String dt1_zy = rs2.getString(zy_dbname);
				String dt1_ysxm = rs2.getString("ysxm");
				String dt1_zflx = rs2.getString("zflx");
				String dt1_bmjjzcfl = rs2.getString("bmjjzcfl");
				String dt1_zfjjzcfl = rs2.getString("zfjjzcfl");
				String dt1_ysly = rs2.getString("ysly");
				String dt1_zcqd = rs2.getString("zcqd");
				String dt1_zcgnkm = rs2.getString("zcgnkm");
				String dt1_bxkmdm = rs2.getString("bxkmdm");
				String dt1_zfl = rs2.getString("zfl");
				String dt1_sqbxje = rs2.getString("sqbxje").equals("")?"0":rs2.getString("sqbxje");
				String dt1_tybxje = rs2.getString("tybxje").equals("")?"0":rs2.getString("tybxje");
				Object[] dt1Params = new Object[]{
						requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,
						dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje
				};
				List<String> dt1data = new ArrayList<>();
				for (Object obj : dt1Params){
					dt1data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt1Datas.add(dt1data);
			}

			rs3.execute("select id,zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
			while(rs3.next()){
				String dt2_id = rs3.getString("id");
				String dt2_zzlx = rs3.getString("zzlx");
				String dt2_zffs = rs3.getString("zffs");
				String dt2_fkyx = rs3.getString("fkyx");
				String dt2_fkzh = rs3.getString("fkzh");
				String dt2_zfje = rs3.getString("zfje").equals("")?"0":rs3.getString("zfje");
				String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
				String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
				Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
				List<String> dt2data = new ArrayList<>();
				for (Object obj : dt2Params){
					dt2data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt2Datas.add(dt2data);
				//rs4.executeUpdate(sql3,dt2Params);
			}
		}
		boolean main_result=true,dt1_result=true,dt2_result=true;
		if(mainDatas.size()>0){
			logTool.writeLog("mainDatas.size="+mainDatas.size());
			logTool.writeLog("dt1Datas.size="+dt1Datas.size());
			logTool.writeLog("dt2Datas.size="+dt2Datas.size());
			main_result = rs4.executeBatchSql(sql1,mainDatas);
			dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
			dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
		}
		logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
		logTool.writeLog("同步BX04结束");
	}
	/**
	 * BX15 奖励金领取 formtable_main_919
	 * @return
	 */
	public void getBx15(){
		logTool.writeLog("同步BX15开始");
		String table = "formtable_main_919";
		String zy_dbname = "jlrymc";//摘要字段
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		RecordSet rs4 = new RecordSet();
		RecordSet getNodeInfo = new RecordSet();
		List<List> mainDatas = new ArrayList<>();
		List<List> dt1Datas = new ArrayList<>();
		List<List> dt2Datas = new ArrayList<>();
		//获取主表信息
		String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype  from "+table+" fm "
				+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
				+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
				+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
				+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
		rs1.execute(mainSql);
		while(rs1.next()){
			String id = rs1.getString("id");
			String requestid = rs1.getString("requestid");
			String jbr = rs1.getString("jbr");
			String jbks = rs1.getString("jbks");
			String jbbm = rs1.getString("jbbm");
			String sqrq = rs1.getString("sqrq");
			String lcbh = rs1.getString("lcbh");
			String currentnodeid = rs1.getString("currentnodeid");
			String currentnodetype = rs1.getString("currentnodetype");
			//获取会计节点的审核人和审核时间
			String operUserid = "";
			String operDate = "";
//			String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//					") and userid=(\n" +
//					"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
			String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
			getNodeInfo.execute(nodeSql);
			if(getNodeInfo.next()){
				operUserid = getNodeInfo.getString("userid");
				operDate = getNodeInfo.getString("operatedate");
			}
			Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
			List<String> maindata = new ArrayList<>();
			for (Object obj : mainParams){
				maindata.add(obj.toString());
			}
			mainDatas.add(maindata);

			rs2.execute("select id,"+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxje,tybxje from "+table+"_dt1 where mainid="+id);
			while(rs2.next()){
				String dt1_id = rs2.getString("id");
				String dt1_zy = rs2.getString(zy_dbname);
				String dt1_ysxm = rs2.getString("ysxm");
				String dt1_zflx = rs2.getString("zflx");
				String dt1_bmjjzcfl = rs2.getString("bmjjzcfl");
				String dt1_zfjjzcfl = rs2.getString("zfjjzcfl");
				String dt1_ysly = rs2.getString("ysly");
				String dt1_zcqd = rs2.getString("zcqd");
				String dt1_zcgnkm = rs2.getString("zcgnkm");
				String dt1_bxkmdm = rs2.getString("bxkmdm");
				String dt1_zfl = rs2.getString("zfl");
				String dt1_sqbxje = rs2.getString("sqbxje").equals("")?"0":rs2.getString("sqbxje");
				String dt1_tybxje = rs2.getString("tybxje").equals("")?"0":rs2.getString("tybxje");
				Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
				List<String> dt1data = new ArrayList<>();
				for (Object obj : dt1Params){
					dt1data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt1Datas.add(dt1data);
			}

			rs3.execute("select id,zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
			while(rs3.next()){
				String dt2_id = rs3.getString("id");
				String dt2_zzlx = rs3.getString("zzlx");
				String dt2_zffs = rs3.getString("zffs");
				String dt2_fkyx = rs3.getString("fkyx");
				String dt2_fkzh = rs3.getString("fkzh");
				String dt2_zfje = rs3.getString("zfje").equals("")?"0":rs3.getString("tyzfje");
				String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
				String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
				Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
				List<String> dt2data = new ArrayList<>();
				for (Object obj : dt2Params){
					dt2data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt2Datas.add(dt2data);
				//rs4.executeUpdate(sql3,dt2Params);
			}
		}
		boolean main_result=true,dt1_result=true,dt2_result=true;
		if(mainDatas.size()>0){
			logTool.writeLog("mainDatas.size="+mainDatas.size());
			logTool.writeLog("dt1Datas.size="+dt1Datas.size());
			logTool.writeLog("dt2Datas.size="+dt2Datas.size());
			main_result = rs4.executeBatchSql(sql1,mainDatas);
			dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
			dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
		}
		logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
		logTool.writeLog("同步BX15结束");
	}
	/**
	 * BX16 通用费用报销 formtable_main_905
	 * @return
	 */
	public void getBx16(){
		logTool.writeLog("同步BX16开始");
		String table = "formtable_main_905";
		String zy_dbname = "wbbz";//摘要字段
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		RecordSet rs4 = new RecordSet();
		RecordSet rs666 = new RecordSet();
		RecordSet getNodeInfo = new RecordSet();
		List<List> mainDatas = new ArrayList<>();
		List<List> dt1Datas = new ArrayList<>();
		List<List> dt2Datas = new ArrayList<>();
		List<String> ids = new ArrayList<>();
		//获取主表信息
		String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype  from "+table+" fm "
				+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
				+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
				+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
				+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%')) ";
		rs1.execute(mainSql);
		while(rs1.next()){
			String id = rs1.getString("id");
			String requestid = rs1.getString("requestid");
			rs666.execute("SELECT * FROM uf_bxjl_kj_dt1 WHERE lcid="+requestid);
			if(!rs666.next()){
				//ids.add(requestid);
			}else{
				continue;
			}
			String jbr = rs1.getString("jbr");
			String jbks = rs1.getString("jbks");
			String jbbm = rs1.getString("jbbm");
			String sqrq = rs1.getString("sqrq");
			String lcbh = rs1.getString("lcbh");
			String currentnodeid = rs1.getString("currentnodeid");
			String currentnodetype = rs1.getString("currentnodetype");
			//获取会计节点的审核人和审核时间
			String operUserid = "";
			String operDate = "";
//			String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//					") and userid=(\n" +
//					"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
			String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
			getNodeInfo.execute(nodeSql);
			if(getNodeInfo.next()){
				operUserid = getNodeInfo.getString("userid");
				operDate = getNodeInfo.getString("operatedate");
			}
			Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
			List<String> maindata = new ArrayList<>();
			for (Object obj : mainParams){
				maindata.add(obj.toString());
			}
			mainDatas.add(maindata);

			rs2.execute("select id,"+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxje,tybxje from "+table+"_dt1 where mainid="+id);
			while(rs2.next()){
				String dt1_id = rs2.getString("id");
				String dt1_zy = rs2.getString(zy_dbname);
				String dt1_ysxm = rs2.getString("ysxm");
				String dt1_zflx = rs2.getString("zflx");
				String dt1_bmjjzcfl = rs2.getString("bmjjzcfl");
				String dt1_zfjjzcfl = rs2.getString("zfjjzcfl");
				String dt1_ysly = rs2.getString("ysly");
				String dt1_zcqd = rs2.getString("zcqd");
				String dt1_zcgnkm = rs2.getString("zcgnkm");
				String dt1_bxkmdm = rs2.getString("bxkmdm");
				String dt1_zfl = rs2.getString("zfl");
				String dt1_sqbxje = rs2.getString("sqbxje").equals("")?"0":rs2.getString("sqbxje");
				String dt1_tybxje = rs2.getString("tybxje").equals("")?"0":rs2.getString("tybxje");
				Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
				List<String> dt1data = new ArrayList<>();
				for (Object obj : dt1Params){
					dt1data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt1Datas.add(dt1data);
			}

			rs3.execute("select id,zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
			while(rs3.next()){
				String dt2_id = rs3.getString("id");
				String dt2_zzlx = rs3.getString("zzlx");
				String dt2_zffs = rs3.getString("zffs");
				String dt2_fkyx = rs3.getString("fkyx");
				String dt2_fkzh = rs3.getString("fkzh");
				String dt2_zfje = rs3.getString("zfje").equals("")?"0":rs3.getString("tyzfje");
				String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
				String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
				Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
				List<String> dt2data = new ArrayList<>();
				for (Object obj : dt2Params){
					dt2data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt2Datas.add(dt2data);
			}
		}
		boolean main_result=true,dt1_result=true,dt2_result=true;
		if(mainDatas.size()>0){
			logTool.writeLog("mainDatas.size="+mainDatas.size());
			logTool.writeLog("dt1Datas.size="+dt1Datas.size());
			logTool.writeLog("dt2Datas.size="+dt2Datas.size());
			main_result = rs4.executeBatchSql(sql1,mainDatas);
			dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
			dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
		}
		logTool.writeLog(ids.toString());
		logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
		logTool.writeLog("同步BX16结束");
	}
	/**
	 * 费用信息跟支付信息都为明细表,明细1中中摘要字段为fysx
	 * @return
	 */
	public void getFulllDetail_fysx(){
		String zy_dbname = "fysx";
		for(String table : fullDetailTable_fysx){
			logTool.writeLog("同步"+table+"开始");
			//根据table查数据
			RecordSet rs1 = new RecordSet();
			RecordSet rs2 = new RecordSet();
			RecordSet rs3 = new RecordSet();
			RecordSet rs4 = new RecordSet();
			RecordSet getNodeInfo = new RecordSet();
			List<List> mainDatas = new ArrayList<>();
			List<List> dt1Datas = new ArrayList<>();
			List<List> dt2Datas = new ArrayList<>();
			//获取主表信息
			String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype  from "+table+" fm "
					+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
					+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
					+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
					+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
			rs1.execute(mainSql);
			while(rs1.next()){
				String id = rs1.getString("id");
				String requestid = rs1.getString("requestid");
				String jbr = rs1.getString("jbr");
				String jbks = rs1.getString("jbks");
				String jbbm = rs1.getString("jbbm");
				String sqrq = rs1.getString("sqrq");
				String lcbh = rs1.getString("lcbh");
				String currentnodeid = rs1.getString("currentnodeid");
				String currentnodetype = rs1.getString("currentnodetype");
				//获取会计节点的审核人和审核时间
				String operUserid = "";
				String operDate = "";
//				String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//						") and userid=(\n" +
//						"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
				String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
				getNodeInfo.execute(nodeSql);
				if(getNodeInfo.next()){
					operUserid = getNodeInfo.getString("userid");
					operDate = getNodeInfo.getString("operatedate");
				}
				Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
				List<String> maindata = new ArrayList<>();
				for (Object obj : mainParams){
					maindata.add(obj.toString());
				}
				mainDatas.add(maindata);

				rs2.execute("select id,"+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxje,tybxje from "+table+"_dt1 where mainid="+id);
				while(rs2.next()){
					String dt1_id = rs2.getString("id");
					String dt1_zy = rs2.getString(zy_dbname);
					String dt1_ysxm = rs2.getString("ysxm");
					String dt1_zflx = rs2.getString("zflx");
					String dt1_bmjjzcfl = rs2.getString("bmjjzcfl");
					String dt1_zfjjzcfl = rs2.getString("zfjjzcfl");
					String dt1_ysly = rs2.getString("ysly");
					String dt1_zcqd = rs2.getString("zcqd");
					String dt1_zcgnkm = rs2.getString("zcgnkm");
					String dt1_bxkmdm = rs2.getString("bxkmdm");
					String dt1_zfl = rs2.getString("zfl");
					String dt1_sqbxje = rs2.getString("sqbxje").equals("")?"0":rs2.getString("sqbxje");
					String dt1_tybxje = rs2.getString("tybxje").equals("")?"0":rs2.getString("tybxje");
					Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
					List<String> dt1data = new ArrayList<>();
					for (Object obj : dt1Params){
						dt1data.add(obj.toString().isEmpty()?"":obj.toString());
					}
					dt1Datas.add(dt1data);
				}

				rs3.execute("select id,zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
				while(rs3.next()){
					String dt2_id = rs3.getString("id");
					String dt2_zzlx = rs3.getString("zzlx");
					String dt2_zffs = rs3.getString("zffs");
					String dt2_fkyx = rs3.getString("fkyx");
					String dt2_fkzh = rs3.getString("fkzh");
					String dt2_zfje = rs3.getString("zfje").equals("")?"0":rs3.getString("tyzfje");
					String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
					String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
					Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
					List<String> dt2data = new ArrayList<>();
					for (Object obj : dt2Params){
						dt2data.add(obj.toString().isEmpty()?"":obj.toString());
					}
					dt2Datas.add(dt2data);
					//rs4.executeUpdate(sql3,dt2Params);
				}
			}
			boolean main_result=true,dt1_result=true,dt2_result=true;
			if(mainDatas.size()>0){
				logTool.writeLog("mainDatas.size="+mainDatas.size());
				logTool.writeLog("dt1Datas.size="+dt1Datas.size());
				logTool.writeLog("dt2Datas.size="+dt2Datas.size());
				main_result = rs4.executeBatchSql(sql1,mainDatas);
				dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
				dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
			}
			logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
			logTool.writeLog("同步"+table+"结束");
		}
	}
	/**
	 * 费用信息跟支付信息都为明细表,明细1无摘要字段
	 * @return
	 */
	public void getFulllDetail_other(){
		RecordSet rs = new RecordSet();
		String zy_dbname = "null";
		for(String table : fullDetailTable_other){
			logTool.writeLog("同步"+table+"开始");
			//根据table查数据
			RecordSet rs1 = new RecordSet();
			RecordSet rs2 = new RecordSet();
			RecordSet rs3 = new RecordSet();
			RecordSet rs4 = new RecordSet();
			RecordSet getNodeInfo = new RecordSet();
			List<List> mainDatas = new ArrayList<>();
			List<List> dt1Datas = new ArrayList<>();
			List<List> dt2Datas = new ArrayList<>();
			//获取主表信息
			String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype  from "+table+" fm "
					+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
					+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
					+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
					+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
			rs1.execute(mainSql);
			while(rs1.next()){
				String id = rs1.getString("id");
				String requestid = rs1.getString("requestid");
				String jbr = rs1.getString("jbr");
				String jbks = rs1.getString("jbks");
				String jbbm = rs1.getString("jbbm");
				String sqrq = rs1.getString("sqrq");
				String lcbh = rs1.getString("lcbh");
				String currentnodeid = rs1.getString("currentnodeid");
				String currentnodetype = rs1.getString("currentnodetype");
				//获取会计节点的审核人和审核时间
				String operUserid = "";
				String operDate = "";
//				String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//						") and userid=(\n" +
//						"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
				String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
				getNodeInfo.execute(nodeSql);
				if(getNodeInfo.next()){
					operUserid = getNodeInfo.getString("userid");
					operDate = getNodeInfo.getString("operatedate");
				}
				Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
				List<String> maindata = new ArrayList<>();
				for (Object obj : mainParams){
					maindata.add(obj.toString());
				}
				mainDatas.add(maindata);

				rs2.execute("select id,"+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxje,tybxje from "+table+"_dt1 where mainid="+id);
				while(rs2.next()){
					String dt1_id = rs2.getString("id");
					String dt1_zy = rs2.getString("zy_dbname");
					String dt1_ysxm = rs2.getString("ysxm");
					String dt1_zflx = rs2.getString("zflx");
					String dt1_bmjjzcfl = rs2.getString("bmjjzcfl");
					String dt1_zfjjzcfl = rs2.getString("zfjjzcfl");
					String dt1_ysly = rs2.getString("ysly");
					String dt1_zcqd = rs2.getString("zcqd");
					String dt1_zcgnkm = rs2.getString("zcgnkm");
					String dt1_bxkmdm = rs2.getString("bxkmdm");
					String dt1_zfl = rs2.getString("zfl");
					String dt1_sqbxje = rs2.getString("sqbxje").equals("")?"0":rs2.getString("sqbxje");
					String dt1_tybxje = rs2.getString("tybxje").equals("")?"0":rs2.getString("tybxje");
					Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
					List<String> dt1data = new ArrayList<>();
					for (Object obj : dt1Params){
						dt1data.add(obj.toString().isEmpty()?"":obj.toString());
					}
					dt1Datas.add(dt1data);
				}

				rs3.execute("select id,zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
				while(rs3.next()){
					String dt2_id = rs3.getString("id");
					String dt2_zzlx = rs3.getString("zzlx");
					String dt2_zffs = rs3.getString("zffs");
					String dt2_fkyx = rs3.getString("fkyx");
					String dt2_fkzh = rs3.getString("fkzh");
					String dt2_zfje = rs3.getString("zfje").equals("")?"0":rs3.getString("tyzfje");
					String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
					String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
					Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
					List<String> dt2data = new ArrayList<>();
					for (Object obj : dt2Params){
						dt2data.add(obj.toString().isEmpty()?"":obj.toString());
					}
					dt2Datas.add(dt2data);
					//rs4.executeUpdate(sql3,dt2Params);
				}
			}
			boolean main_result=true,dt1_result=true,dt2_result=true;
			if(mainDatas.size()>0){
				logTool.writeLog("mainDatas.size="+mainDatas.size());
				logTool.writeLog("dt1Datas.size="+dt1Datas.size());
				logTool.writeLog("dt2Datas.size="+dt2Datas.size());
				main_result = rs4.executeBatchSql(sql1,mainDatas);
				dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
				dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
			}
			logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
			logTool.writeLog("同步"+table+"结束");
		}
	}
	/**
	 * 费用信息跟支付信息都为明细表--人员经费，明细1中摘要字段为zy
	 * @return
	 */
	public void getFulllDetail_RY(){
		RecordSet rs = new RecordSet();
		String zy_dbname = "zy";//摘要字段
		for(String table : fullDetailTable_RY){
			//根据table查数据
			logTool.writeLog("同步"+table+"开始");
			//根据table查数据
			RecordSet rs1 = new RecordSet();
			RecordSet rs2 = new RecordSet();
			RecordSet rs3 = new RecordSet();
			RecordSet rs4 = new RecordSet();
			RecordSet getNodeInfo = new RecordSet();
			List<List> mainDatas = new ArrayList<>();
			List<List> dt1Datas = new ArrayList<>();
			List<List> dt2Datas = new ArrayList<>();
			//获取主表信息
			String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype  from "+table+" fm "
					+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
					+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
					+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
					+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%会计主管%'))";
			logTool.writeLog("获取主表信息sql>"+mainSql);
			rs1.execute(mainSql);
			while(rs1.next()){
				String id = rs1.getString("id");
				String requestid = rs1.getString("requestid");
				String jbr = rs1.getString("jbr");
				String jbks = rs1.getString("jbks");
				String jbbm = rs1.getString("jbbm");
				String sqrq = rs1.getString("sqrq");
				String lcbh = rs1.getString("lcbh");
				String currentnodeid = rs1.getString("currentnodeid");
				String currentnodetype = rs1.getString("currentnodetype");
				//获取会计节点的审核人和审核时间
				String operUserid = "";
				String operDate = "";
//				String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计主管%')\n" +
//						") and userid=(\n" +
//						"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计主管%') )) and islasttimes=1";
				String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
						"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
						"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
						"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%主管')) order by LOGID desc";
				getNodeInfo.execute(nodeSql);
				if(getNodeInfo.next()){
					operUserid = getNodeInfo.getString("userid");
					operDate = getNodeInfo.getString("operatedate");
				}
				Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
				List<String> maindata = new ArrayList<>();
				for (Object obj : mainParams){
					maindata.add(obj.toString());
				}
				mainDatas.add(maindata);

				rs2.execute("select id,"+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxje,tybxje from "+table+"_dt1 where mainid="+id);
				while(rs2.next()){
					String dt1_id = rs2.getString("id");
					String dt1_zy = rs2.getString("zy_dbname");
					String dt1_ysxm = rs2.getString("ysxm");
					String dt1_zflx = rs2.getString("zflx");
					String dt1_bmjjzcfl = rs2.getString("bmjjzcfl");
					String dt1_zfjjzcfl = rs2.getString("zfjjzcfl");
					String dt1_ysly = rs2.getString("ysly");
					String dt1_zcqd = rs2.getString("zcqd");
					String dt1_zcgnkm = rs2.getString("zcgnkm");
					String dt1_bxkmdm = rs2.getString("bxkmdm");
					String dt1_zfl = rs2.getString("zfl");
					String dt1_sqbxje = rs2.getString("sqbxje").equals("")?"0":rs2.getString("sqbxje");
					String dt1_tybxje = rs2.getString("tybxje").equals("")?"0":rs2.getString("tybxje");
					Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
					List<String> dt1data = new ArrayList<>();
					for (Object obj : dt1Params){
						dt1data.add(obj.toString().isEmpty()?"":obj.toString());
					}
					dt1Datas.add(dt1data);
				}

				rs3.execute("select id,zzlx,zffs,fkyx,zfzh,sqzfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
				while(rs3.next()){
					String dt2_id = rs3.getString("id");
					String dt2_zzlx = rs3.getString("zzlx");
					String dt2_zffs = rs3.getString("zffs");
					String dt2_fkyx = rs3.getString("fkyx");
					String dt2_fkzh = rs3.getString("zfzh");
					String dt2_zfje = rs3.getString("sqzfje").equals("")?"0":rs3.getString("tyzfje");
					String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
					String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
					Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
					List<String> dt2data = new ArrayList<>();
					for (Object obj : dt2Params){
						dt2data.add(obj.toString().isEmpty()?"":obj.toString());
					}
					dt2Datas.add(dt2data);
					//rs4.executeUpdate(sql3,dt2Params);
				}
			}
			boolean main_result=true,dt1_result=true,dt2_result=true;
			if(mainDatas.size()>0){
				logTool.writeLog("mainDatas.size="+mainDatas.size());
				logTool.writeLog("dt1Datas.size="+dt1Datas.size());
				logTool.writeLog("dt2Datas.size="+dt2Datas.size());
				main_result = rs4.executeBatchSql(sql1,mainDatas);
				dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
				dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
			}
			logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
			logTool.writeLog("同步"+table+"结束");
		}
	}
	/**
	 * 费用信息在主表，支付信息在明细2--BX06 培训费报销，摘要字段为pxxmjh  formtable_main_896
	 * @return
	 */
	public void getBx06(){
		logTool.writeLog("同步BX06开始");
		String table = "formtable_main_896";
		String zy_dbname = "pxxmjh";//摘要字段
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		RecordSet rs4 = new RecordSet();
		RecordSet getNodeInfo = new RecordSet();
		List<List> mainDatas = new ArrayList<>();
		List<List> dt1Datas = new ArrayList<>();
		List<List> dt2Datas = new ArrayList<>();
		//获取主表信息
		String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype,"
				+"\n "+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxjehj,tybxje from "+table+" fm "
				+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
				+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
				+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
				+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
		rs1.execute(mainSql);
		while(rs1.next()){
			String id = rs1.getString("id");
			String requestid = rs1.getString("requestid");
			String jbr = rs1.getString("jbr");
			String jbks = rs1.getString("jbks");
			String jbbm = rs1.getString("jbbm");
			String sqrq = rs1.getString("sqrq");
			String lcbh = rs1.getString("lcbh");
			String currentnodeid = rs1.getString("currentnodeid");
			String currentnodetype = rs1.getString("currentnodetype");
			//获取会计节点的审核人和审核时间
			String operUserid = "";
			String operDate = "";
//			String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//					") and userid=(\n" +
//					"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
			String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
			getNodeInfo.execute(nodeSql);
			if(getNodeInfo.next()){
				operUserid = getNodeInfo.getString("userid");
				operDate = getNodeInfo.getString("operatedate");
			}
			Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
			List<String> maindata = new ArrayList<>();
			for (Object obj : mainParams){
				maindata.add(obj.toString());
			}
			mainDatas.add(maindata);

			String dt1_id = rs1.getString("id");
			String dt1_zy = rs1.getString(zy_dbname);
			String dt1_ysxm = rs1.getString("ysxm");
			String dt1_zflx = rs1.getString("zflx");
			String dt1_bmjjzcfl = rs1.getString("bmjjzcfl");
			String dt1_zfjjzcfl = rs1.getString("zfjjzcfl");
			String dt1_ysly = rs1.getString("ysly");
			String dt1_zcqd = rs1.getString("zcqd");
			String dt1_zcgnkm = rs1.getString("zcgnkm");
			String dt1_bxkmdm = rs1.getString("bxkmdm");
			String dt1_zfl = rs1.getString("zfl");
			String dt1_sqbxje = rs1.getString("sqbxje").equals("")?"0":rs1.getString("sqbxje");
			String dt1_tybxje = rs1.getString("tybxje").equals("")?"0":rs1.getString("tybxje");
			Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
			List<String> dt1data = new ArrayList<>();
			for (Object obj : dt1Params){
				dt1data.add(obj.toString().isEmpty()?"":obj.toString());
			}
			dt1Datas.add(dt1data);

			rs3.execute("select id,zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+"_dt2 where mainid="+id);
			while(rs3.next()){
				String dt2_id = rs3.getString("id");
				String dt2_zzlx = rs3.getString("zzlx");
				String dt2_zffs = rs3.getString("zffs");
				String dt2_fkyx = rs3.getString("fkyx");
				String dt2_fkzh = rs3.getString("fkzh");
				String dt2_zfje = rs3.getString("zfje").equals("")?"0":rs3.getString("zfje");
				String dt2_tyzfje = rs3.getString("tyzfje").equals("")?"0":rs3.getString("tyzfje");
				String dt2_gwkskje = rs3.getString("gwkskje").equals("")?"0":rs3.getString("gwkskje");
				Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
				List<String> dt2data = new ArrayList<>();
				for (Object obj : dt2Params){
					dt2data.add(obj.toString().isEmpty()?"":obj.toString());
				}
				dt2Datas.add(dt2data);
				//rs4.executeUpdate(sql3,dt2Params);
			}
		}
		boolean main_result=true,dt1_result=true,dt2_result=true;
		if(mainDatas.size()>0){
			logTool.writeLog("mainDatas.size="+mainDatas.size());
			logTool.writeLog("dt1Datas.size="+dt1Datas.size());
			logTool.writeLog("dt2Datas.size="+dt2Datas.size());
			main_result = rs4.executeBatchSql(sql1,mainDatas);
			dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
			dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
		}
		logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
		logTool.writeLog("同步BX06结束");
	}
	/**
	 * 费用信息跟支付信息都在主表--BX10 缉私举报奖金报销，没有摘要字段 formtable_main_900
	 * @return
	 */
	public void getBx10(){
		logTool.writeLog("同步BX10开始");
		String table = "formtable_main_900";
		String zy_dbname = "null";//摘要字段
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		RecordSet rs4 = new RecordSet();
		RecordSet getNodeInfo = new RecordSet();
		List<List> mainDatas = new ArrayList<>();
		List<List> dt1Datas = new ArrayList<>();
		List<List> dt2Datas = new ArrayList<>();
		//获取主表信息
		String mainSql = "select id,fm.requestid,jbry as jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype,"
				+"\n "+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxjehj,tybxje,"
				+" zzlx,zffs,fkyx,fkzh,zfje,tyzfje,gwkskje from "+table+" fm "
				+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
				+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
				+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
				+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
		rs1.execute(mainSql);
		while(rs1.next()){
			String id = rs1.getString("id");
			String requestid = rs1.getString("requestid");
			String jbr = rs1.getString("jbr");
			String jbks = rs1.getString("jbks");
			String jbbm = rs1.getString("jbbm");
			String sqrq = rs1.getString("sqrq");
			String lcbh = rs1.getString("lcbh");
			String currentnodeid = rs1.getString("currentnodeid");
			String currentnodetype = rs1.getString("currentnodetype");
			//获取会计节点的审核人和审核时间
			String operUserid = "";
			String operDate = "";
//			String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//					") and userid=(\n" +
//					"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
			String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
			getNodeInfo.execute(nodeSql);
			if(getNodeInfo.next()){
				operUserid = getNodeInfo.getString("userid");
				operDate = getNodeInfo.getString("operatedate");
			}
			Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
			List<String> maindata = new ArrayList<>();
			for (Object obj : mainParams){
				maindata.add(obj.toString());
			}
			mainDatas.add(maindata);

			String dt1_id = rs1.getString("id");
			String dt1_zy = rs1.getString(zy_dbname);
			String dt1_ysxm = rs1.getString("ysxm");
			String dt1_zflx = rs1.getString("zflx");
			String dt1_bmjjzcfl = rs1.getString("bmjjzcfl");
			String dt1_zfjjzcfl = rs1.getString("zfjjzcfl");
			String dt1_ysly = rs1.getString("ysly");
			String dt1_zcqd = rs1.getString("zcqd");
			String dt1_zcgnkm = rs1.getString("zcgnkm");
			String dt1_bxkmdm = rs1.getString("bxkmdm");
			String dt1_zfl = rs1.getString("zfl");
			String dt1_sqbxje = rs1.getString("sqbxje").equals("")?"0":rs1.getString("sqbxje");
			String dt1_tybxje = rs1.getString("tybxje").equals("")?"0":rs1.getString("tybxje");
			Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
			List<String> dt1data = new ArrayList<>();
			for (Object obj : dt1Params){
				dt1data.add(obj.toString().isEmpty()?"":obj.toString());
			}
			dt1Datas.add(dt1data);

			String dt2_id = rs1.getString("id");
			String dt2_zzlx = rs1.getString("zzlx");
			String dt2_zffs = rs1.getString("zffs");
			String dt2_fkyx = rs1.getString("fkyx");
			String dt2_fkzh = rs1.getString("fkzh");
			String dt2_zfje = rs1.getString("zfje").equals("")?"0":rs1.getString("zfje");
			String dt2_tyzfje = rs1.getString("tyzfje").equals("")?"0":rs1.getString("tyzfje");
			String dt2_gwkskje = rs1.getString("gwkskje").equals("")?"0":rs1.getString("gwkskje");
			Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
			List<String> dt2data = new ArrayList<>();
			for (Object obj : dt2Params){
				dt2data.add(obj.toString().isEmpty()?"":obj.toString());
			}
			dt2Datas.add(dt2data);
			//rs4.executeUpdate(sql3,dt2Params);
		}
		boolean main_result=true,dt1_result=true,dt2_result=true;
		if(mainDatas.size()>0){
			logTool.writeLog("mainDatas.size="+mainDatas.size());
			logTool.writeLog("dt1Datas.size="+dt1Datas.size());
			logTool.writeLog("dt2Datas.size="+dt2Datas.size());
			main_result = rs4.executeBatchSql(sql1,mainDatas);
			dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
			dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
		}
		logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
		logTool.writeLog("同步BX10结束");
	}
	/**
	 * 费用信息跟支付信息都在主表--BX27 借款申请，摘要字段为jkyy  formtable_main_911
	 * @return
	 */
	public void getBx27(){
		logTool.writeLog("同步BX27开始");
		String table = "formtable_main_911";
		String zy_dbname = "jkyy";//摘要字段
		RecordSet rs1 = new RecordSet();
		RecordSet rs2 = new RecordSet();
		RecordSet rs3 = new RecordSet();
		RecordSet rs4 = new RecordSet();
		RecordSet getNodeInfo = new RecordSet();
		List<List> mainDatas = new ArrayList<>();
		List<List> dt1Datas = new ArrayList<>();
		List<List> dt2Datas = new ArrayList<>();
		//获取主表信息
		String mainSql = "select id,fm.requestid,jbr,jbks,jbbm,sqrq,lcbh,currentnodeid,currentnodetype,"
				+"\n "+zy_dbname+",ysxm,zflx,bmjjzcfl,zfjjzcfl,ysly,zcqd,zcgnkm,bxkmdm,zfl,sqbxjehj,tybxje,"
				+" zzlx,zffs,fkyx,fkzh,zfje,tybxje as tyzfje,gwkskje from "+table+" fm "
				+"\n left join workflow_requestbase wb on fm.requestid=wb.requestid where wb.currentnodeid in( "
				+"\n select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id "
				+"\n where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr "
				+"\n on fm.requestid = wr.requestid) and (wn.nodename like'%归档%' or wn.nodename like'%出纳%'))";
		rs1.execute(mainSql);
		while(rs1.next()){
			String id = rs1.getString("id");
			String requestid = rs1.getString("requestid");
			String jbr = rs1.getString("jbr");
			String jbks = rs1.getString("jbks");
			String jbbm = rs1.getString("jbbm");
			String sqrq = rs1.getString("sqrq");
			String lcbh = rs1.getString("lcbh");
			String currentnodeid = rs1.getString("currentnodeid");
			String currentnodetype = rs1.getString("currentnodetype");
			//获取会计节点的审核人和审核时间
			String operUserid = "";
			String operDate = "";
//			String nodeSql = "select userid,operatedate from workflow_currentoperator where  requestid="+requestid+" and  nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')\n" +
//					") and userid=(\n" +
//					"select operator from workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
//					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
//					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
//					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%') )) and islasttimes=1";
			String nodeSql = "select top 1 operator as userid,operatedate as operatedate from  workflow_requestlog where requestid="+requestid+" and destnodeid<>nodeid and logtype in('0') and nodeid=(\n" +
					"select nodeid from workflow_flownode wfn left join workflow_nodebase wn on wfn.nodeid=wn.id \n" +
					"where workflowid=(select top 1 workflowid from "+table+" fm left join workflow_requestbase wr \n" +
					"on fm.requestid = wr.requestid) and (wn.nodename like'%会计%')) order by LOGID desc";
			getNodeInfo.execute(nodeSql);
			if(getNodeInfo.next()){
				operUserid = getNodeInfo.getString("userid");
				operDate = getNodeInfo.getString("operatedate");
			}
			Object[] mainParams = new Object[]{requestid,requestid,jbr,jbks,jbbm,sqrq,lcbh,operUserid,operDate,currentnodeid,currentnodetype};
			List<String> maindata = new ArrayList<>();
			for (Object obj : mainParams){
				maindata.add(obj.toString());
			}
			mainDatas.add(maindata);

			String dt1_id = rs1.getString("id");
			String dt1_zy = rs1.getString(zy_dbname);
			String dt1_ysxm = rs1.getString("ysxm");
			String dt1_zflx = rs1.getString("zflx");
			String dt1_bmjjzcfl = rs1.getString("bmjjzcfl");
			String dt1_zfjjzcfl = rs1.getString("zfjjzcfl");
			String dt1_ysly = rs1.getString("ysly");
			String dt1_zcqd = rs1.getString("zcqd");
			String dt1_zcgnkm = rs1.getString("zcgnkm");
			String dt1_bxkmdm = rs1.getString("bxkmdm");
			String dt1_zfl = rs1.getString("zfl");
			String dt1_sqbxje = rs1.getString("sqbxje").equals("")?"0":rs1.getString("sqbxjehj");
			String dt1_tybxje = rs1.getString("tybxje").equals("")?"0":rs1.getString("tybxje");
			Object[] dt1Params = new Object[]{requestid,dt1_id,dt1_zy,dt1_zflx,dt1_ysxm,dt1_bmjjzcfl,dt1_zfjjzcfl,dt1_bxkmdm,dt1_zcqd,dt1_ysly,dt1_zcgnkm,dt1_zfl,dt1_sqbxje,dt1_tybxje};
			List<String> dt1data = new ArrayList<>();
			for (Object obj : dt1Params){
				dt1data.add(obj.toString().isEmpty()?"":obj.toString());
			}
			dt1Datas.add(dt1data);

			String dt2_id = rs1.getString("id");
			String dt2_zzlx = rs1.getString("zzlx");
			String dt2_zffs = rs1.getString("zffs");
			String dt2_fkyx = rs1.getString("fkyx");
			String dt2_fkzh = rs1.getString("fkzh");
			String dt2_zfje = rs1.getString("zfje").equals("")?"0":rs1.getString("zfje");
			String dt2_tyzfje = rs1.getString("tyzfje").equals("")?"0":rs1.getString("tyzfje");
			String dt2_gwkskje = rs1.getString("gwkskje").equals("")?"0":rs1.getString("gwkskje");
			Object[] dt2Params = new Object[]{requestid,dt2_id,dt2_zzlx,dt2_zffs,dt2_fkyx,dt2_fkzh,dt2_zfje,dt2_tyzfje,dt2_gwkskje};
			List<String> dt2data = new ArrayList<>();
			for (Object obj : dt2Params){
				dt2data.add(obj.toString().isEmpty()?"":obj.toString());
			}
			dt2Datas.add(dt2data);
			//rs4.executeUpdate(sql3,dt2Params);
		}
		boolean main_result=true,dt1_result=true,dt2_result=true;
		if(mainDatas.size()>0){
			logTool.writeLog("mainDatas.size="+mainDatas.size());
			logTool.writeLog("dt1Datas.size="+dt1Datas.size());
			logTool.writeLog("dt2Datas.size="+dt2Datas.size());
			main_result = rs4.executeBatchSql(sql1,mainDatas);
			dt1_result = rs4.executeBatchSql(sql2,dt1Datas);
			dt2_result = rs4.executeBatchSql(sql3,dt2Datas);
		}
		logTool.writeLog("main_result="+main_result+"  dt1_result="+dt1_result+"  dt2_result="+dt2_result);
		logTool.writeLog("同步BX27结束");
	}
}
